/*
 ============================================================================
 Name		: ActivityManager.h
 Author	  : 
 Version	 : 1.0
 Copyright   : Your copyright notice
 Description : CActivityManager declaration
 ============================================================================
 */

#ifndef __ACTIVITYMANAGER_H__
#define __ACTIVITYMANAGER_H__

#include <e32std.h>
#include <e32base.h>

class MActivityManagerObserver
	{
public:
	virtual void ActivityDetected() = 0;
	virtual void InactivityDetected() = 0;
	};

class CActivityManager : public CActive
	{
public:
	static CActivityManager* NewL(MActivityManagerObserver* aObserver,
			TInt aTimeout = 60);
	~CActivityManager();
	void SetTimeout(TInt aTimeout);
	TBool Start();
	void Reset();

protected:
	// from CActive 
	void DoCancel();
	void RunL();

protected:
	CActivityManager(MActivityManagerObserver* aObserver, TInt aTimeout);
	void ConstructL();

protected:
	enum TWatch
		{
		EWaitingForNone = 0, 
		EWaitingForInactivity, 
		EWaitingForActivity
		};

protected:

	RTimer iTimer;
	TWatch iWatch;
	MActivityManagerObserver *iObserver; ///The observer of activity status
	TInt iTimeout; ///Current inactivity period

	};

#endif // ACTIVITYMANAGER_H
